<template>
  <div>
    <section>
      <div class="section-header">
        <span>政策利用</span>
        <div>
        <a-button class="hte-btn port-btn"  @click="handleExportExcel" :loading="exportLoading" >导出</a-button>
        <a-input-search v-model="valueSearch" @search="doSearch" :allowClear="true" placeholder="支持模糊搜索" />
        </div>
      </div>
      <div class="section-table">
        <div>
          <a-table
            class="hte-table-content"
            :columns="reservationColumns"
            :data-source="reservationData"
            :pagination="pagination"
            :loading="tabLoading"
             :scroll="{ x: true }"     
            bordered
            size="middle"
            @change="pageChange"
          >
          <template slot="passFlag" slot-scope="text">
              <span >{{text?'通过':'不通过'}}</span>
            </template>
             <template slot="link" slot-scope="text">
              <span >{{text?'涉及':'不涉及'}}</span>
            </template>
          </a-table>
        </div>
      </div>
    </section>
  </div>
</template>
<script>
import { getAction,downloadFileLink } from '@/api/manage'

export default {
  name: 'InfoPolicy',
  props: {
    companyId: {
      type: String,
      default: '',
    },
  },
  components: {},
  data() {
    return {
      reservationColumns: [
         {
          title: '公司名称',
          dataIndex: 'companyName',
           width: '150px',
          align: 'center',
        },
          {
          title: '项目名称',
          dataIndex: 'projectName',
           width: '150px',
          align: 'center',
        },
          {
          title: '项目编号',
          dataIndex: 'projectNo',
          width: '90px',
          align: 'center',
        }
        ,
        {
          title: '项目状态',
          dataIndex: 'projectStatusName',
          width: '90px',
          align: 'center',
        }
        ,
        {
          title: '申报时间',
          dataIndex: 'declarationTime',
          width: '90px',
          align: 'center',
        },
        {
          title: '文件名称',
          dataIndex: 'fileName',
         width: '250px',
          align: 'center',
        },
        {
          title: '责任机构',
          dataIndex: 'organization',
       width: '150px',
          align: 'center',
        },
        {
          title: '级别',
          dataIndex: 'policyLevel',
          width: '90px',
          align: 'center',
        },
        {
          title: '申报结果',
          dataIndex: 'declarationResult',
          width: '150px',
          align: 'center',
        },
        {
          title: '通过情况',
          dataIndex: 'timeMb.passFlag',
          width: '150px',
          align: 'center',
          scopedSlots: { customRender: 'passFlag' }
        },
        // {
        //   title: '荣誉名称申报',
        //   dataIndex: 'timeMb.honorFlag',
        //    width: '150px',
        //   align: 'center',
        //    scopedSlots: { customRender: 'link' }
        // },
         {
          title: '荣誉资质',
          dataIndex: 'timeMb.honorName',
          width: '150px',
          align: 'center',
        },
        // {
        //   title: '扶持资金申报',
        //   dataIndex: 'timeMb.supportFlag',
        //  width: '150px',
        //   align: 'center',
        //   scopedSlots: { customRender: 'link' }
        // },
        {
          title: '预计扶持资金(万元)',
          dataIndex: 'timeMb.supportMoney',
          width: '150px',
          align: 'center',
        },
          {
          title: '资金入账(万元)',
          dataIndex: 'incomeMonthly',
           width: '150px',
          align: 'center',
        },
        {
          title: '项目经理',
          dataIndex: 'projectManager',
         width: '150px',
          align: 'center',
        },
      ],
      reservationData: [],
      pagination: {
        total: 0,
        current: 1,
      },
      tabLoading: false,
      currPageIndex: 1,
      currPageSize: 10,
      valueSearch: '',
      exportLoading:false,
    }
  },
  mounted() {
    this.queryPolicyData()
  },
  methods: {
    handleExportExcel(){
      let param = {companyId:this.companyId};
  
      console.log("导出参数",param)
      this.exportLoading = true;
      downloadFileLink('/libraryCompany/hteLibCompany/policyExportXls','政策利用.xls', param,{type: 'application/vnd.ms-excel'}).then((data)=>{
        this.exportLoading = false;
      })
  
    },
    pageChange() {
      this.currPageIndex = page.current
      this.currPageSize = page.pageSize
      this.pagination.current = page.current
      this.queryPolicyData()
    },
    doSearch() {
      this.currPageIndex = 1
      this.queryPolicyData()
    },
    /**
     * 公司库团队信息
     */
    queryPolicyData() {
      this.tabLoading = true
      getAction('/libraryCompany/hteLibCompany/queryPolicy', {
        companyId: this.companyId,
        keyword: this.valueSearch,
        pageSize: this.currPageSize,
        pageNo: this.currPageIndex
      }).then((res) => {
        if (res.code == 200 && res.result) {
          this.pagination.total = res.result.total
          res.result.records.forEach((item, index) => {
            item.key = index
          })
          this.reservationData = res.result.records
          this.tabLoading = false
        } else {
          this.$message.warning('数据加载失败:' + res.message)
          this.tabLoading = false
        }
      })
    },
  },
}
</script>
<style lang="less" scoped>
@import '~@assets/less/hte-main.less';
.section-header {
  /deep/ .ant-input-search {
    width: 280px;
  }
}
</style>